/*
 * Copyright (c) 2015. For Intelligent Group.
 */

package com.intelligent.ispc.client.core.view.analysis.grr;

import com.intelligent.ispc.chart.grr.APlotChart;
import com.intelligent.ispc.chart.grr.ComponentsChart;
import com.intelligent.ispc.chart.grr.RPlotChart;
import com.intelligent.ispc.chart.grr.XBarOrRChart;
import com.intelligent.ispc.client.core.controller.GrrController;
import com.intelligent.ispc.client.core.modal.grr.*;
import com.intelligent.ispc.client.core.modal.grr.AnovaTableModel;
import com.intelligent.ispc.client.core.modal.grr.ItemDetailTableModel;
import com.intelligent.ispc.client.core.modal.grr.SourceTableModel;
import com.intelligent.ispc.client.core.modal.grr.SummaryTableModel;
import com.intelligent.ispc.client.core.view.AbstractPanel;
import com.intelligent.ispc.client.core.view.analysis.grr.render.ItemDetailRender;
import com.intelligent.ispc.client.core.view.analysis.grr.render.SourceHeaderRender;
import com.intelligent.ispc.client.core.view.analysis.grr.render.SummaryRender;
import com.intelligent.ispc.client.ex.dynamictable.DyLoadTask;
import com.intelligent.ispc.client.ex.dynamictable.DyTableLoader;
import com.intelligent.ispc.client.ex.dynamictable.DyTablePanel;
import com.intelligent.ispc.client.utils.*;
import com.intelligent.ispc.common.utils.ResourceBundleUtils;
import com.intelligent.ispc.common.utils.StringUtils;
import com.intelligent.ispc.constant.AppConstant;
import com.intelligent.ispc.core.dto.*;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.PostConstruct;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.util.List;

/**
 * Created by cherry on 2016/9/2.
 */
@org.springframework.stereotype.Component
public class AnalysisPanel extends AbstractPanel {

    @Autowired
    private GrrController grrController;

    private SummaryTableModel summaryModel;
    private ItemDetailTableModel testItemModel;
    private ConfigModel configModel;
    private AnovaTableModel anovaModel;
    private SourceTableModel sourceModel;
    private DefaultComboBoxModel comboBoxModel;

    private GrrGroupDto currentGroup;

    private Integer currentRow;
    private String fileName;
    private String filePath;
    private boolean flag;

    private static final int PAGE_SIZE = 30;
    private int itemCount = UIConstant.DEFAULT_ITEM_COUNT;

    /**
     * Analysis panel constructor
     */
    public AnalysisPanel() {
    }

    @Override
    public void initDataSource() {
        summaryModel.setRules(configModel.getRules());
        summaryModel.initDigNum();
    }

    @Override
    public void initView() {
        summaryTable.getTableHeader().setVisible(true);
        anovaTable.getTableHeader().setVisible(true);
        sourceTable.getTableHeader().setVisible(true);
        summaryTable.getTableHeader().setReorderingAllowed(false);
        sourceTable.getTableHeader().setReorderingAllowed(false);
        summaryTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }

    @Override
    @PostConstruct
    public void initComponents() {
        this.setLayout(new GridBagLayout());
        testItemPanel = new JPanel(new GridBagLayout());
        anovaPanel = new JPanel(new GridBagLayout());
        sourcePanel = new JPanel(new GridBagLayout());
        chartsPanel = new JPanel(new GridBagLayout());
        this.setBorder(BorderFactory.createEmptyBorder());

        itemInfoLbl = new JLabel();
        anovaInfoLbl = new JLabel();
        summaryTable = new EditTable();
        testItemTable = new JTable();
        anovaTable = new JTable();
        sourceTable = new JTable();
        categoryLbl = new JLabel();

        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();
        tcr.setHorizontalAlignment(SwingConstants.CENTER);

        summaryTable.setDefaultRenderer(Object.class, tcr);
        anovaTable.setDefaultRenderer(Object.class, tcr);
        sourceTable.setDefaultRenderer(Object.class, tcr);
        sourceTable.getTableHeader().setDefaultRenderer(new SourceHeaderRender());

        String[] columns = AppConstant.GRR_SUMMARY_TB_TITLE;
        summaryModel = new SummaryTableModel();
        summaryModel.setColumns(columns);
        loader = new DyTableLoader(summaryModel, 0, PAGE_SIZE, DyTableLoader.ROW, null);
        loader.setNormalModel(summaryModel);
        summaryPanel = new DyTablePanel(loader);
        summaryPanel.setBorder(BorderFactory.createTitledBorder("Summary"));
        final Dimension summaryPanelSize = new Dimension(300, 250);
        summaryPanel.setPreferredSize(summaryPanelSize);
        summaryPanel.setDataTable(summaryTable);

        testItemScrollPanel = new JScrollPane(testItemTable);
        final Dimension itemPanelSize = new Dimension(100, 280);
        testItemScrollPanel.setPreferredSize(itemPanelSize);
        testItemScrollPanel.setBorder(BorderFactory.createEmptyBorder());

        String[] sigmaValues = new String[]{"5.15", "6.00"};
        comboBoxModel = new DefaultComboBoxModel(sigmaValues);

        sigmaComboBox = new JComboBox();
        sigmaComboBox.setModel(comboBoxModel);

        subPanel = new JPanel(new GridBagLayout());
        subPanel.setBorder(BorderFactory.createEmptyBorder());
        subPanel.add(testItemPanel, new GBC(0, 0).setFill(GBC.BOTH).setWeight(100, 0));
        subPanel.add(anovaPanel, new GBC(0, 1).setFill(GBC.BOTH).setWeight(100, 0));
        subPanel.add(sourcePanel, new GBC(0, 2).setFill(GBC.BOTH).setWeight(100, 0));
        subPanel.add(chartsPanel, new GBC(0, 3).setFill(GBC.BOTH).setWeight(100, 100));

        JScrollPane mainScrollPane = new JScrollPane();
        JPanel mainPanel = new JPanel(new GridBagLayout());
        mainScrollPane.setBorder(BorderFactory.createEmptyBorder());
        mainPanel.setBorder(BorderFactory.createEmptyBorder());

        initSubTableComponents();
        mainPanel.add(summaryPanel, new GBC(0, 0).setFill(GBC.BOTH).setWeight(100, 0));
        mainPanel.add(subPanel, new GBC(0, 1).setFill(GBC.BOTH).setWeight(100, 100));
        mainScrollPane.setViewportView(mainPanel);
        this.add(mainScrollPane, new GBC(0, 0).setFill(GBC.BOTH).setWeight(100, 100));

        initComponentsEvent();
    }

    /**
     * load summary table
     */
    public void loadSummary() {
        resetSubPanel();

        GrrParamDto grrParamDto = new GrrParamDto();
        grrParamDto.setFilePath(filePath);
        DyLoadTask task = new DyLoadTask() {
            @Override
            public List<GrrSummaryDto> load(int start, int end) {
                java.util.List<GrrSummaryDto> list = grrController.findGrrSummary(grrParamDto, currentGroup, start, end);
                if (start == 0) {
                    loader.initPageCount(itemCount);
                }
                return list;
            }
        };

        loader.setTask(task);
        summaryPanel.loadData();
        SummaryRender render = new SummaryRender(summaryPanel.getDataTable());
        summaryPanel.getDataTable().setDefaultRenderer(Object.class, render);
        this.updateUI();
    }

    /**
     * load sub tables and charts
     *
     * @param grrResultDto sub tables and charts data source
     */
    public void loadSubItem(GrrResultDto grrResultDto) {
        if (grrResultDto != null) {
            loadTestItem(grrResultDto.getGrrViewDataDtoList(), grrResultDto.getGrrStatisticDataDtoList());
            loadAnova(grrResultDto.getGrrAnovaDtoList());
            loadSource(grrResultDto.getGrrSourceDtoList());
            loadCharts(grrResultDto.getGrrChartDto());
        }
    }

    /**
     * search sub tables and charts data
     *
     * @param sigma current selected sigma value
     */
    public void loadSubTableData(String sigma) {
        String itemName = summaryModel.getData().get(currentRow).getItemName();
        String tolerance = summaryModel.getData().get(currentRow).getTolerance();
        String usl = summaryModel.getData().get(currentRow).getUsl();
        String lsl = summaryModel.getData().get(currentRow).getLsl();

        GrrParamDto grrParamDto = new GrrParamDto();
        grrParamDto.setGrrName(fileName);
        grrParamDto.setFilePath(filePath);
        grrParamDto.setItemName(itemName);
        grrParamDto.setUsl(usl);
        grrParamDto.setLsl(lsl);
        String anovaInfo = "USL : " + usl + ", LSL : " + lsl;
        anovaInfoLbl.setText(anovaInfo);
        String itemInfo = "TestItem : " + itemName + ", Tolerance : " + tolerance;
        itemInfoLbl.setText(itemInfo);

        if (!StringUtils.isBlank(sigma)) {
            grrParamDto.setSigma(sigma);

        } else {
            if ("5.15".equals(configModel.getSigma())) {
                sigmaComboBox.setSelectedIndex(0);
            } else {
                sigmaComboBox.setSelectedIndex(1);
            }
        }
        grrController.findGrrResult(grrParamDto, currentGroup, null);
    }

    private void loadTestItem(List<GrrViewDataDto> grrViewDataDtos, List<GrrStatisticDataDto> grrStatisticDataDtos) {
        if (grrViewDataDtos == null || grrViewDataDtos.isEmpty()) {
            return;
        }
        List<KeyValueDto> colValueDtos = grrViewDataDtos.get(0).getColValueDtoList();
        if (colValueDtos == null || colValueDtos.isEmpty()) {
            return;
        }

        String firstColumnName = AppConstant.GRR_FIRST_CHANGE_OPERATOR;
        String[] columnsBefore = new String[]{firstColumnName, AppConstant.GRR_FIRST_CHANGE_TRIAL};
        int colValueSize;
        colValueSize = colValueDtos.size();
        String[] columnsAfter = new String[colValueSize];

        for (int i = 0; i < colValueDtos.size(); i++) {
            columnsAfter[i] = colValueDtos.get(i).getKey();
        }
        String[] columns = ArrayUtils.concat(columnsBefore, columnsAfter);
        testItemModel = new ItemDetailTableModel(configModel.getAppraiserCount(), configModel.getTrialCount(), columns);
        testItemModel.initDigGrrNum();
        testItemModel.setData(grrViewDataDtos, grrStatisticDataDtos);
        testItemTable.setModel(testItemModel);

        ItemDetailRender render = new ItemDetailRender(testItemTable);
        testItemTable.setDefaultRenderer(Object.class, render);
        resizeItemTable(true);
    }

    private void resizeItemTable(boolean bool) {
        Dimension containerWidth = null;
        if (!bool) {
            containerWidth = testItemScrollPanel.getPreferredSize();
        } else {
            containerWidth = testItemScrollPanel.getSize();
        }
        int allWidth = testItemTable.getIntercellSpacing().width;
        final int widthPlus = 10;
        for (int j = 0; j < testItemTable.getColumnCount(); j++) {
            int maxNum = 0;
            for (int i = 0; i < testItemTable.getRowCount(); i++) {
                int width = testItemTable.
                        getCellRenderer(i, j).getTableCellRendererComponent(testItemTable, testItemTable.getValueAt(i, j), false,
                        false, i, j).getPreferredSize().width;
                if (width > maxNum) {
                    maxNum = width;
                }
            }
            maxNum += widthPlus;
            testItemTable.getColumnModel().
                    getColumn(j).setPreferredWidth(maxNum);
            allWidth += maxNum + testItemTable.getIntercellSpacing().width;
        }
        allWidth += testItemTable.getIntercellSpacing().width;
        if (allWidth > containerWidth.width) {
            testItemTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        } else {
            testItemTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
        }
    }

    private void loadAnova(List<GrrAnovaDto> grrAnovaDtos) {
        String[] colunms = AppConstant.GRR_ANOVA_TB_TITLE;
        anovaModel = new AnovaTableModel(colunms);
        anovaModel.initDigGrrNum();
        anovaModel.setData(grrAnovaDtos);
        anovaTable.setModel(anovaModel);
    }

    private void loadSource(List<GrrSourceDto> grrSourceDtos) {
        String[] columns = AppConstant.GRR_SOURCE_TB_TITLE;
        columns[3] = comboBoxModel.getSelectedItem().toString();
        sourceModel = new SourceTableModel(columns);
        sourceModel.initDigNum();
        sourceTable.setModel(sourceModel);
        sourceModel.setData(grrSourceDtos);
        String categories = "Number of Distinct Categories : ";
        String value = "-";
        if (!grrSourceDtos.isEmpty()) {
            int size = grrSourceDtos.size();
            value = grrSourceDtos.get(size - 1).getDistincCategories();
        }
        categoryLbl.setText(categories + value);
    }

    private void loadCharts(GrrChartDto grrChartDto) {
        if (chartsPanel != null) {
            chartsPanel.removeAll();
        } else {
            chartsPanel = new JPanel(new GridBagLayout());
        }

        XBarOrRChart xBarChart = new XBarOrRChart(grrChartDto.getXbarValue(), "Xbar-Chart", configModel.getPartCount());
        XBarOrRChart rChart = new XBarOrRChart(grrChartDto.getrValue(), "R-Chart", configModel.getPartCount());
        RPlotChart appraiserChart = new RPlotChart(grrChartDto.getResByOperatorValue(), "R&R Plot – By Appraisers", configModel.getPartCount(), configModel.getTrialCount());
        RPlotChart partChart = new RPlotChart(grrChartDto.getResByPartValue(), "R&R Plot – By Parts", configModel.getAppraiserCount(), configModel.getTrialCount());
        ComponentsChart componentsChart = new ComponentsChart(grrChartDto.getComponentValue());
        APlotChart aPlotChart = new APlotChart(grrChartDto.getAplotValue(), configModel.getAppraiserCount(), configModel.getPartCount());

        xBarChart.initDigNumFormat(AppConstant.ANALYSIS_GRR_DIGNUM);
        rChart.initDigNumFormat(AppConstant.ANALYSIS_GRR_DIGNUM);
        appraiserChart.initDigNumFormat(AppConstant.ANALYSIS_GRR_DIGNUM);
        partChart.initDigNumFormat(AppConstant.ANALYSIS_GRR_DIGNUM);
        componentsChart.initDigNumFormat(AppConstant.ANALYSIS_GRR_DIGNUM);
        aPlotChart.initDigNumFormat(AppConstant.ANALYSIS_GRR_DIGNUM);

        final Dimension chartPanelSize = new Dimension(500, 1500);
        chartsPanel.setPreferredSize(chartPanelSize);

        chartsPanel.add(xBarChart.createChartPanel(), new GBC(0, 0).setFill(GBC.BOTH).setWeight(100, 100));
        chartsPanel.add(rChart.createChartPanel(), new GBC(0, 1).setFill(GBC.BOTH).setWeight(100, 100));
        chartsPanel.add(appraiserChart.createChartPanel(), new GBC(0, 2).setFill(GBC.BOTH).setWeight(100, 100));
        chartsPanel.add(partChart.createChartPanel(), new GBC(0, 3).setFill(GBC.BOTH).setWeight(100, 100));
        chartsPanel.add(componentsChart.createChartPanel(), new GBC(0, 4).setFill(GBC.BOTH).setWeight(100, 100));
        chartsPanel.add(aPlotChart.createChartPanel(), new GBC(0, 5).setFill(GBC.BOTH).setWeight(100, 100));
        chartsPanel.updateUI();
    }

    private void showSubComponents() {
        subPanel.add(testItemPanel, new GBC(0, 0).setFill(GBC.BOTH).setWeight(100, 0));
        subPanel.add(anovaPanel, new GBC(0, 1).setFill(GBC.BOTH).setWeight(100, 0));
        subPanel.add(sourcePanel, new GBC(0, 2).setFill(GBC.BOTH).setWeight(100, 0));
        subPanel.add(chartsPanel, new GBC(0, 3).setFill(GBC.BOTH).setWeight(100, 100));
        this.updateUI();
        flag = true;
    }

    private void initSubTableComponents() {
        JScrollPane anovaScrollPanel = new JScrollPane();
        final Dimension anovaScrollPaneSize = new Dimension(250, 110);
        anovaScrollPanel.setPreferredSize(anovaScrollPaneSize);
        anovaScrollPanel.setViewportView(anovaTable);
        JScrollPane sourceScrollPanel = new JScrollPane();
        final Dimension sourceScrollPaneSize = new Dimension(250, 140);
        sourceScrollPanel.setPreferredSize(sourceScrollPaneSize);
        sourceScrollPanel.setViewportView(sourceTable);

        testItemPanel.setBorder(BorderFactory.createTitledBorder("TestItem"));
        anovaPanel.setBorder(BorderFactory.createTitledBorder("Analysis"));
        sourcePanel.setBorder(BorderFactory.createTitledBorder("Source"));
        chartsPanel.setBorder(BorderFactory.createTitledBorder("Charts"));

        testItemPanel.add(itemInfoLbl, new GBC(0, 0).setFill(GBC.BOTH).setInsets(5, 0, 10, 0));
        testItemPanel.add(testItemScrollPanel, new GBC(0, 1).setFill(GBC.BOTH).setWeight(100, 100));
        anovaPanel.add(anovaInfoLbl, new GBC(0, 0).setFill(GBC.BOTH).setInsets(5, 0, 10, 0));
        anovaPanel.add(anovaScrollPanel, new GBC(0, 1).setFill(GBC.BOTH).setWeight(100, 100));

        JPanel sourceInfoPanel = new JPanel();
        sourceInfoPanel.setLayout(new GridBagLayout());
        sourceInfoPanel.add(new JLabel("Process Distribution Width in Sigma's (Typically 5.15 or 6.00) = "), new GBC(0, 0).setFill(GBC.BOTH).setInsets(5, 0, 10, 0));
        sourceInfoPanel.add(sigmaComboBox, new GBC(1, 0).setFill(GBC.BOTH).setInsets(5, 0, 10, 0));
        sourceInfoPanel.add(new JLabel(), new GBC(2, 0).setFill(GBC.BOTH).setWeight(100, 100).setInsets(5, 0, 10, 0));

        sourcePanel.add(sourceInfoPanel, new GBC(0, 0).setFill(GBC.BOTH));
        sourcePanel.add(sourceScrollPanel, new GBC(0, 1).setFill(GBC.BOTH).setWeight(100, 100));
        sourcePanel.add(categoryLbl, new GBC(0, 2).setFill(GBC.BOTH).setWeight(100, 0).setInsets(10, 5, 5, 0));
    }

    private void clearSubTableData() {
        if (testItemModel != null) {
            testItemModel.setData(null, null);
        }

        if (anovaModel != null) {
            anovaModel.setData(null);
        }

        if (sourceModel != null) {
            sourceModel.setData(null);
        }

        itemInfoLbl.setText("");
        anovaInfoLbl.setText("");
    }

    private void initComponentsEvent() {

        summaryTable.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                super.mouseClicked(e);
                Point p = e.getPoint();
                int column = summaryTable.columnAtPoint(p);
                currentRow = summaryTable.rowAtPoint(p);
                String grr = summaryModel.getData().get(currentRow).getGrr();
                if (column == 6 && StringUtils.isNumeric(grr) && Double.valueOf(grr) >= 0) {
                    if (!flag) {
                        showSubComponents();
                    }
                    loadSubTableData(null);
                }
            }
        });

        summaryTable.addEditedListener(new EditedListener() {
            @Autowired
            public void execute(Object value, int editRow, int editColumn) {
                currentRow = editRow;
                GrrParamDto grrParamDto = new GrrParamDto();
                grrParamDto.setFilePath(filePath);
                grrParamDto.setGrrName(fileName);

                if (editColumn == 1) {
                    if (!checkValue(value)) {
                        return;
                    } else {
                        if (StringUtils.isNumeric(summaryModel.getData().get(editRow).getUsl())) {
                            Double lsl = Double.parseDouble(value.toString());
                            Double usl = Double.parseDouble(summaryModel.getData().get(editRow).getUsl());
                            if (lsl >= usl) {
                                AppMessageFactory.showErrorDialog(ResourceBundleUtils.getString(ExceptionMessages.EXCEPTION_GRR_USL_MORE_THAN_LSL));
                                return;
                            }
                        }
                        grrParamDto.setLsl(value.toString());
                        grrParamDto.setUsl(summaryModel.getData().get(editRow).getUsl());
                    }
                } else if (editColumn == 2) {
                    if (!checkValue(value)) {
                        return;
                    } else {
                        if (StringUtils.isNumeric(summaryModel.getData().get(editRow).getUsl())) {
                            Double lsl = Double.parseDouble(summaryModel.getData().get(editRow).getLsl());
                            Double usl = Double.parseDouble(value.toString());
                            if (lsl >= usl) {
                                AppMessageFactory.showErrorDialog(ResourceBundleUtils.getString(ExceptionMessages.EXCEPTION_GRR_USL_MORE_THAN_LSL));
                                return;
                            }
                        }
                    }
                    grrParamDto.setUsl(value.toString());
                    grrParamDto.setLsl(summaryModel.getData().get(editRow).getLsl());
                }

                String itemName = summaryModel.getData().get(editRow).getItemName();
                grrParamDto.setItemName(itemName);
                java.util.List<GrrSummaryDto> dtos = grrController.findGrrSummary(grrParamDto, currentGroup, currentRow, currentRow + 1);

                if (dtos != null && !dtos.isEmpty()) {
                    summaryModel.setRowData(currentRow, dtos.get(0));
                    if (flag) {
                        loadSubTableData(null);
                    }
                }
            }
        });

        sigmaComboBox.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    String sigma = sigmaComboBox.getSelectedItem().toString();
                    loadSubTableData(sigma);
                }
            }
        });

        testItemScrollPanel.addComponentListener(new ComponentAdapter() {
            @Override
            public void componentResized(ComponentEvent e) {
                int columnCount = testItemTable.getColumnCount();
                if (columnCount == 0) {
                    return;
                }
                resizeItemTable(true);
            }
        });
    }

    /**
     * reset analysis panel, refresh ui
     */
    public void resetAnalysisPanel() {
        summaryModel.setData(null);
        currentGroup = null;
        summaryPanel.clearAndRefreshTables();
        itemCount = UIConstant.DEFAULT_ITEM_COUNT;
        resetSubPanel();
        this.updateUI();
    }

    private void resetSubPanel() {
        flag = false;
        subPanel.removeAll();
        clearSubTableData();
    }

    private boolean checkValue(Object value) {
        if (!StringUtils.isNumeric(value.toString())) {
            AppMessageFactory.showErrorDialog(ResourceBundleUtils.getString(ExceptionMessages.EXCEPTION_GRR_NO_INPUT_NUMBER));
            return false;
        } else {
            return true;
        }
    }

    /**
     * extend JTable to use defined edit method
     */
    static class EditTable extends JTable {
        private Object currentEditValue;
        private EditedListener event;

        @Override
        public void editingStopped(ChangeEvent e) {
            TableCellEditor editor = getCellEditor();
            if (editor != null) {
                Object value = editor.getCellEditorValue();
                currentEditValue = value;
            }

            int row = this.editingRow;
            int column = this.editingColumn;
            event.execute(currentEditValue, row, column);
            removeEditor();
        }

        @Override
        public void setCellSelectionEnabled(boolean cellSelectionEnabled) {
            setRowSelectionAllowed(cellSelectionEnabled);
            setColumnSelectionAllowed(cellSelectionEnabled);
            boolean old = this.cellSelectionEnabled;
            this.cellSelectionEnabled = cellSelectionEnabled;
            firePropertyChange("cellSelectionEnabled", old, cellSelectionEnabled);
        }

        public void addEditedListener(EditedListener event) {
            this.event = event;
        }

        public Object getCurrentEditValue() {
            return currentEditValue;
        }
    }

    /**
     * Edited Listener
     */
    interface EditedListener {
        void execute(Object value, int editRow, int editColumn);

    }

    /**
     * set filePath and fileName
     *
     * @param filePath current selected file for filePath
     * @param fileName current selected file for fileName
     */
    public void setFilePathAndName(String filePath, String fileName) {
        this.filePath = filePath;
        this.fileName = fileName;
    }

    public void setCurrentGroup(GrrGroupDto currentGroup) {
        this.currentGroup = currentGroup;
    }

    public void setConfigModel(ConfigModel configModel) {
        this.configModel = configModel;
    }

    public void setItemCount(int itemCount) {
        this.itemCount = itemCount;
    }

    private JPanel subPanel;
    private JPanel testItemPanel;
    private JPanel anovaPanel;
    private JPanel sourcePanel;
    private JPanel chartsPanel;

    private EditTable summaryTable;
    private JTable testItemTable;
    private JTable anovaTable;
    private JTable sourceTable;

    private DyTableLoader loader;
    private DyTablePanel summaryPanel;
    private JScrollPane testItemScrollPanel;
    private JLabel itemInfoLbl;
    private JLabel anovaInfoLbl;
    private JComboBox sigmaComboBox;
    private JLabel categoryLbl;
}
